<template>
  <!--<div>login
    <router-link to="/">back</router-link>
  </div>-->
  <div>
    用户:
    <Input v-model="username" style="width: 300px" /><br><br> 
    密码:
    <Input v-model="password" style="width: 300px" /><br><br>

    <Button type="primary" style="width: 330px" @click="login">登录</Button><br><br>
    <router-link to="/register">注册</router-link>
  </div>

</template>
<script>
import service from '../../service/index'
export default {
  name: "login",
  // mounted() {
  //   console.log(this.$route.query.id)
  // },
  data:()=>{
    return{
      username:'',
      password:''
    }
  },
  methods: {
    login (e) {
      console.log(this.username, this.password)
      service.post('/login',{
        body: JSON.stringify({
          userName: this.username,
          passWord: this.password
        })
      })
      .then((res)=>{
        console.log(res)
        if(res.retcode===1){
          this.$router.push({ path: '/'})
        }
        
      })
    }
  }
};
</script>

<style lang="scss" scoped>

</style>
